<?
$PageTitle=$msg["Page_Plugins"];
$toppage = "find";

include "div_menu.php";

db_init_tags();
query_form();

//-----------------------------------------------------------------------------

function query_form() 
{
  global $msg;
  global $url;
  global $tags0;
  global $tags1;
?>

<!-- Query form -->

<div class="form_area">
<div class="form_div">

<form class="plug_find_form" action="plugins" method="get">

<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">

  <dl>
    <dt><label for="category"><?=$msg["PlugCat"];?></label></dt>
    <dd>
      <select  tabindex="1" name="category" id="category">
       <option value=""></option>
<?
      foreach ($tags0 as $tag_key => $tag_name)
      {
        print "<option value=\"{$tag_key}\">{$tag_name}</option>\n";
      };
?>
      </select>
    </dd>
  </dl>

  <dl>
    <dt><label for="name"><?=$msg["FindText"];?></label></dt>
    <dd><input type="text" size="80" tabindex="2" name="name" id="name"/></dd>
  </dl>

  <dl>
    <dt><label for="author"><?=$msg["PlugAuthor"];?></label></dt>
    <dd><input type="text" size="80" tabindex="3" name="author" id="author"/></dd>
  </dl>

  <dl>
    <dt><label for="tag"><?=$msg["PlugLabels"];?></label></dt>
<!--<dd><input type="text" size="80" tabindex="4" name="tag" id="tag"/></dd>-->
    <dd>
    <?print_tag_combo("tag", ""); print_tag_combo("tag", ""); print_tag_combo("tag", "");?>
    </dd>
  </dl>

  <dl>
    <dt><label for="updated"><?=$msg["FindUpdated"];?></label></dt>
    <dd>
      <select tabindex="5" name="updated" id="updated">
        <option value=""></option>
        <option value="1"><?=$msg["PastDay"];?></option>
        <option value="2"><?=$msg["PastWeek"];?></option>
        <option value="3"><?=$msg["PastMonth"];?></option>
        <option value="4"><?=$msg["PastYear"];?></option>
      </select>
    </dd>
  </dl>

  <dl>
    <dt><label for="sortby"><?=$msg["SortBy"];?></label></dt>
    <dd>
      <select tabindex="6" name="sortby" id="sortby">
        <option value="1"><?=$msg["SortByName"];?></option>
        <option value="2"><?=$msg["SortByUpdate"];?></option>
        <option value="3"><?=$msg["SortByRating"];?></option>
      </select>
    </dd>
  </dl>

</td>


<td valign="top" style="width:190px">

  <dl>
  <fieldset class="tags_fieldset" style="width:190px">
    <legend><?=$msg["PlugCompat"];?></legend>
<?
    foreach ($tags1 as $tag_key => $tag_name)
    {
      print "<input type=\"checkbox\" class=\"checkbox\" name=\"tag\" value=\"{$tag_key}\">{$tag_name}</input><br>\n";
    };
?>
  </fieldset>
  </dl>

</td>

</tr>

<tr>
  <td colspan="2">

    <dl class="button_div">
      <button type="submit" tabindex="6"><?=$msg["Search"]?></button>
      &nbsp;
      <button type="reset" tabindex="8"><?=$msg["Cancel"]?></button>
    </dl>

  </td>
</tr>

</table>

</form>

</div>
</div>

<?php
};


//-----------------------------------------------------------------------------

function print_tag_combo($name, $tag)
{
  global $tags2;

//print "<div style=\"margin:0 5 5 5\">\n";
  print "<select name=\"$name\" id=\"$name\" style=\"width:190px\">\n";

  print "<option value=\"\"></option>";

  foreach ($tags2 as $tag_key => $tag_name)
  {
    $selected = ($tag == $tag_key) ? "selected" : "";
    print "<option value=\"{$tag_key}\" $selected>{$tag_name}</option>\n";
  };

  print "</select>\n";
//print "</div>\n";
}

?>